package com.gpframework.common.core.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.gpframework.common.core.domain.entity.*;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @Author gpframework
 */
public class TreeSelectVo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private String id;

    /**
     * 菜单标识
     */
    private String code;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectVo> children;

    public TreeSelectVo() {

    }

    public TreeSelectVo(SysDept dept) {
        this.id = dept.getBrandDeptId().toString();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public TreeSelectVo(PlatformDept dept) {
        this.id = dept.getDeptId().toString();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public TreeSelectVo(SysMenuVo menuVo) {
        this.id = menuVo.getMenuId();
        this.label = menuVo.getMenuName();
        this.children = menuVo.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public TreeSelectVo(PlatformMenu menu) {
        this.id = menu.getMenuId().toString();
        this.label = menu.getMenuName();
        this.code = menu.getCode();
        this.children = menu.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public TreeSelectVo(PlatformMenuVo menu) {
        this.id = menu.getMenuId();
        this.label = menu.getMenuName();
        this.code = menu.getCode();
        this.children = menu.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<TreeSelectVo> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelectVo> children) {
        this.children = children;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
